/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.opgea.appstreet.dao.impl;

import com.opgea.appstreet.dao.CompanyLoginDAO;
import com.opgea.appstreet.domain.entities.CompanyLogin;
import java.util.List;

import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

/**
 *
 * @author Ramesh
 */
@Repository
public class CompanyLoginDAOImpl implements CompanyLoginDAO{
    
    
    @Autowired
    private SessionFactory sessionFactory;

    @Override
    public CompanyLogin create(CompanyLogin companyLogin) {
        Session session = sessionFactory.openSession();
        Transaction tx = session.getTransaction();
        tx.begin();
        session.save(companyLogin);
        tx.commit();
        session.close();
        return companyLogin;
    }

    @Override
    public CompanyLogin update(CompanyLogin companyLogin) {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    @Override
    public CompanyLogin delete(String loginId) {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    @Override
    public CompanyLogin find(String loginId) {
        Session session = sessionFactory.openSession();
        Transaction tx = session.getTransaction();
        tx.begin();
        Query query = session.getNamedQuery("CompanyLogin.findByLoginId");
        query.setParameter("loginId", loginId);
        CompanyLogin companyLogin = (CompanyLogin) query.uniqueResult();
        tx.commit();
        session.close();
        return companyLogin;
    }

    @Override
    public CompanyLogin findByCompanyId(Long companyId) {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    @Override
    public List<CompanyLogin> findAll() {
        throw new UnsupportedOperationException("Not supported yet.");
    }
    
}
